# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
set(CMAKE_CXX_FLAGS_DEBUG   "-O0 -g" )             # 调试包不优化
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG " )   # release包优化

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")  # 开启所有警告
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -Wall")
#aux_source_directory(${CMAKE_SOURCE_DIR}/src/main/cpp/ SOURCES)
#message("SOURCES:" ${SOURCES})
#file(GLOB TUTORIAL_LESSON1 "src/main/cpp/tutorial/lesson1/*.h")
add_library(
            # Sets the name of the library.
            lesson-lib

            # Sets the library as a shared library.
            SHARED

            # Provides a relative path to your source file(s).
            src/main/cpp/util/XqLog.h
            src/main/cpp/util/XqLog.cpp
            src/main/cpp/util/Shader.h
            src/main/cpp/util/Shader.cpp
            src/main/cpp/util/GLUtils.h
            src/main/cpp/util/GLUtils.cpp
            src/main/cpp/util/ShaderHelper.cpp
            src/main/cpp/util/ShaderHelper.h
            src/main/cpp/util/GLTexture.h
            src/main/cpp/tutorial/TutorialLesson.h
            src/main/cpp/tutorial/TutorialLesson.cpp
            src/main/cpp/graphics/Matrix.h
            src/main/cpp/graphics/Matrix.cpp

            #tutorial lesson1
            src/main/cpp/tutorial/lesson1/TutorialLessonOneNative.h
            src/main/cpp/tutorial/lesson1/TutorialLessonOneNative.cpp
            src/main/cpp/tutorial/lesson1/TutorialLessonOne.h
            src/main/cpp/tutorial/lesson1/TutorialLessonOne.cpp

            #tutorial lesson2
            src/main/cpp/tutorial/lesson2/TutorialLessonTwoNative.h
            src/main/cpp/tutorial/lesson2/TutorialLessonTwoNative.cpp
            src/main/cpp/tutorial/lesson2/TutorialLessonTwo.h
            src/main/cpp/tutorial/lesson2/TutorialLessonTwo.cpp

            #tutorial lesson3
            src/main/cpp/tutorial/lesson3/TutorialLessonThreeNative.h
            src/main/cpp/tutorial/lesson3/TutorialLessonThreeNative.cpp
            src/main/cpp/tutorial/lesson3/TutorialLessonThree.h
            src/main/cpp/tutorial/lesson3/TutorialLessonThree.cpp

            #tutorial lesson4
            src/main/cpp/tutorial/lesson4/TutorialLessonFourNative.h
            src/main/cpp/tutorial/lesson4/TutorialLessonFourNative.cpp
            src/main/cpp/tutorial/lesson4/TutorialLessonFour.h
            src/main/cpp/tutorial/lesson4/TutorialLessonFour.cpp

            #tutorial lesson5
            src/main/cpp/tutorial/lesson5/TutorialLessonFiveNative.h
            src/main/cpp/tutorial/lesson5/TutorialLessonFiveNative.cpp
            src/main/cpp/tutorial/lesson5/TutorialLessonFive.h
            src/main/cpp/tutorial/lesson5/TutorialLessonFive.cpp
             )

include_directories(src/main/cpp/)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
                       lesson-lib
                       EGL
                       GLESv2
                       android
                       #jni read bitmap library
                       jnigraphics
                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib} )